<?php
/**
 * 组件管理Control类
 * @file		ComponentsControl.class.php
 * @author     	kelecode@gmail.com
 * @date       	2013-06-14
 * modify
 */
class ComponentsControl extends Control{

	public function __construct(){
		parent::__construct();
	}
	
	public function index(){
		$this->lists();
	}

	/**
	 * 组件列表
	 */
	public function lists(){
		$items = M('Components')->extensionsList();
		$tinyPage = new TinyPage( $items['count'],C('page.page_size') );
        $page = $tinyPage->show();

		$main = APP_ROOT . '/template/' . C('theme') . '/components/lists.php';
		$this->assign('main',$main);
		$this->assign('title','组件列表');
		$this->assign('lists',$items['lists']);
		$this->assign('page',$page);
		$this->display('layout', 'common');
	}
	
	public function set(){
		echo 'set';
	}

	public function install(){
		if($_POST['do'] == 1){
			$data = array(
				'extension_id' => '',
				'title' => '',
				'alias' => '',
				'type' => '',
				'params' => '',
				'ordering' => '',
				'status' => '',
			);
			M('Components')->install($data);
		}else{
			$main = APP_ROOT . '/template/' . C('theme') . '/components/install.php';
			$this->assign('main',$main);
			$this->assign('title','安装组件');
			$this->display('layout', 'common');
		}
	}

	public function uninstall(){
		echo 'uninstall';
	}

}